package com.jbpm.util;

import java.io.File;
import java.io.InputStream;
import java.util.Properties;

import com.emms.common.util.BaseUtil;

/**
 * 系统常来读取
 * @author Administrator
 *
 */
public  class SysPropertiesRead {

	//创建相应目录信息
	public SysPropertiesRead() {
		//目录创建
		mkdirsFile(jpdl_path);
	}
	
	//系统域名
	public final static String sys_url=readValue("sys_url");
	
	//系统jpdl访问路径
	public final static String jpdl_url=readValue("jpdl_url");
		
	//文件存放路径
	public final static String jpdl_path=readValue("jpdl_path");
	
	//文件存放路径发布路径
	public final static String jpdl_update_path=readValue("jpdl_update_path");
		
	//文件目录创建
	public static void mkdirsFile(String path){
		File _temPath= new File(path);
		if(!BaseUtil.isEmpty(path)){
			_temPath.mkdirs();
		}
	}
	
	 /**
	  * 根据key读取value
	  * @param filePath
	  * @param key
	  * @return
	  */
	private static String readValue(String key) {
        Properties props = new Properties();
        try {
	         InputStream in =SysPropertiesRead.class.getResourceAsStream("/properties/sys.properties");;
	         props.load(in);
	         String value = props.getProperty (key);
             return value;
        } catch (Exception e) {
	         e.printStackTrace();
	         return null;
        }
	 }
	 
}
